package com.itheima.mapper;

import com.itheima.domain.Orders;
import org.apache.ibatis.annotations.Many;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.mapping.FetchType;

import java.util.List;

/**
 * @param
 * @return
 */
public interface OrdersMapper {
    @Select("select * from orders where user_id =#{id}")
    @Results({
            @Result(column = "number",property = "number"),
            @Result(property = "itemsList" ,javaType = List.class,column = "id",
            many = @Many(select ="com.itheima.mapper.ItemsMapper.findById" ,fetchType = FetchType.LAZY))
    })
    List<Orders> findById(int id);
}
